<?php

namespace app\model;


use think\Model;

class TaskWorkOrderModel extends Model
{

    const STATUS_UNTREATED = 0; // 未处理
    const STATUS_PROCESSED = 1; // 已结单
    const STATUS_EXPIRED = 2; // 已撤销
    const STATUS_PROGRESS = 3; // 处理中

    const TYPE_TASK_MAKING = 'task_making';

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'task_work_order';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    // 设置json字段
    protected $json = ['json','directory_template','config'];
    // 设置JSON数据返回数组
    protected $jsonAssoc = true;


    /**
     * 关联task数据模型
     * @return \think\model\relation\HasOne
     */
    public function task()
    {
        return $this->hasOne(TaskModel::class, 'id', 'task_id');
    }

    /**
     * 关工工单问题环节
     * @return \think\model\relation\HasMany
     */
    public function taskWorkOrderProblemStepCategory()
    {
        return $this->hasMany(TaskWorkOrderProblemStepCategoryModel::class,'task_work_order_id','id');
    }
}
